
package com.insigma.business.qrcode.common.converter;


import com.insigma.business.qrcode.job.dto.TrainingMentorDTO;
import com.insigma.business.qrcode.job.dto.request.TrainingMentorInsertRequest;
import com.insigma.business.qrcode.job.dto.request.TrainingMentorSearchRequest;
import com.insigma.business.qrcode.job.dto.request.TrainingMentorUpdateRequest;
import com.insigma.business.qrcode.job.dto.search.TrainingMentorBSearcher;
import com.insigma.business.qrcode.job.entity.TrainingMentorDO;
import org.springframework.beans.BeanUtils;

import java.util.List;


public class TrainingMentorProviderConverter extends AbstractConverter<TrainingMentorDTO, TrainingMentorDO> {

    private final static TrainingMentorProviderConverter trainingMentorConverter = new TrainingMentorProviderConverter();

    private TrainingMentorProviderConverter(){}

    
    public static TrainingMentorBSearcher convertRequestSO2Searcher(final TrainingMentorSearchRequest request){
        final TrainingMentorBSearcher trainingMentorBSearcher = new TrainingMentorBSearcher(request.getPageNo(),
        request.getPageSize(),request.getSortKeyValueJoint());
        BeanUtils.copyProperties(request,trainingMentorBSearcher);
        return trainingMentorBSearcher;
    }

    
    public static TrainingMentorDO convertRequestUO2DO(final TrainingMentorUpdateRequest trainingMentorUpdateRequest) {
        final TrainingMentorDO trainingMentorDO = new TrainingMentorDO();
        BeanUtils.copyProperties(trainingMentorUpdateRequest,trainingMentorDO);
        
        return trainingMentorDO;
    }

    
    public static TrainingMentorDO convertRequestIO2DO(final TrainingMentorInsertRequest trainingMentorInsertRequest) {
        final TrainingMentorDO trainingMentorDO = new TrainingMentorDO();
        BeanUtils.copyProperties(trainingMentorInsertRequest,trainingMentorDO);
        return trainingMentorDO;
    }

    
    public static List<TrainingMentorDTO> convertResponseDOList2DTOList(final List<TrainingMentorDO> trainingMentorDOList){
        return trainingMentorConverter.convertGenericResponseDOList2DTOList(trainingMentorDOList);
    }

    
    public static TrainingMentorDTO convertResponseDO2DTO(final TrainingMentorDO trainingMentorDO){
        return trainingMentorConverter.convertGenericResponseDO2DTO(trainingMentorDO);
    }

    
    @Override
    protected TrainingMentorDTO doConvertResponseDO2DTO(TrainingMentorDO trainingMentorDO) {
        final TrainingMentorDTO trainingMentorDTO = new TrainingMentorDTO();
        try {
            BeanUtils.copyProperties(trainingMentorDO, trainingMentorDTO);
        }catch(RuntimeException be){
            
            return null;
        }
        return trainingMentorDTO;
    }

}
